package tr.richfacesext.components.captcha;

import javax.faces.component.UIComponent;
import javax.faces.webapp.UIComponentTag;

import tr.richfacesext.components.ComponentUtils;

/**
 * 
 * @author mert
 *
 */
public class CaptchaTag extends UIComponentTag {

	private String _maxLength = null;
	private String _letterWidth = null;
	private String _imgHeight = null;
	private String _imgSkew = null;
	private String _drawLines = null;
	private String _drawBoxes = null;
	private String _invertColors = null;

	public void release(){
		super.release();
		_maxLength = null;
		_letterWidth = null;
		_imgHeight = null;
		_imgSkew = null;
		_drawLines = null;
		_drawBoxes = null;
		_invertColors = null;
	}

	protected void setProperties(UIComponent uicomponent){
		super.setProperties(uicomponent);

		ComponentUtils.setIntegerProperty(getFacesContext(), uicomponent, "maxLength", _maxLength );
		ComponentUtils.setIntegerProperty(getFacesContext(), uicomponent, "letterWidth", _letterWidth );
		ComponentUtils.setIntegerProperty(getFacesContext(), uicomponent, "imgHeight", _imgHeight );
		ComponentUtils.setDoubleProperty(getFacesContext(), uicomponent, "imgSkew", _imgSkew );
		ComponentUtils.setIntegerProperty(getFacesContext(), uicomponent, "drawLines", _drawLines );
		ComponentUtils.setIntegerProperty(getFacesContext(), uicomponent, "drawBoxes", _drawBoxes );
		ComponentUtils.setBooleanProperty(getFacesContext(), uicomponent, "invertColors", _invertColors );
	}

	public String getComponentType() {
		return Captcha.COMPONENT_TYPE;
	}

	public String getRendererType() {
		return "tr.richfacesext.components.captcha.CaptchaRenderer";
	}

	public void setMaxLength(String value){
		_maxLength = value;
	}

	public void setLetterWidth(String value){
		_letterWidth = value;
	}

	public void setImgHeight(String value){
		_imgHeight = value;
	}

	public void setImgSkew(String value){
		_imgSkew = value;
	}

	public void setDrawLines(String value){
		_drawLines = value;
	}

	public void setDrawBoxes(String value){
		_drawBoxes = value;
	}

	public void setInvertColors(String value){
		_invertColors = value;
	}

}